import {AreaOfTriangle, TriangleInfo} from "./AreaOfTriangle";
import {Vertex2} from "./Direction2D";
import {roundNumber} from "../number/roundNumber";

let OneVertexWithinTriangle = (vt: Vertex2, triangle: TriangleInfo) => {
    let [v0, v1, v2] = triangle;
    let areaTotal = AreaOfTriangle(triangle);
    let area0 = AreaOfTriangle([vt, v0, v1]);
    let area1 = AreaOfTriangle([vt, v1, v2]);
    let area2 = AreaOfTriangle([vt, v2, v0]);

    let areaGap = areaTotal - area0 - area1 - area2;
    return roundNumber(areaGap, 8) === 0;
};

export {OneVertexWithinTriangle};